<%@ page import="nuaa.util.UtilSqlSession" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="nuaa.dao.IIndexDao" %>
<%@ page import="nuaa.domain.Index" %>
<%@ page import="java.util.List" %>
<%@ page import="nuaa.domain.Group" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Group Travel</title>
    <%--引入css页面--%>
    <link rel="stylesheet" type="text/css" href="css/index.css">
</head>
<body>
<%@include file="/WEB-INF/parts/head.jsp"%>

<%--标题，指明应用内容--%>
<%--<h2 class="content-name" style="font-family: STSong"><b>Group Travel</b></h2>--%>
<p class="content-name">
    <b style="font-family: STSong">Group Travel</b>
    <span id="announceContent" style="color: red; float: right;margin-right: 10%;">公告：${applicationScope.announceContent}</span>
</p>
<%--最新队伍的标识--%>
<h2 class="content-latest_group"><b>最新队伍</b></h2>

<%--队伍信息，最多5个--%>
<%--获取列表--%>
<%
    //1.获取indexDao对象
    IIndexDao indexDao = UtilSqlSession.getSqlSession().getMapper(IIndexDao.class);
    //2.调用对象的查询方法，获取groups
    List<Group> groups = indexDao.getGroups();
    //3.将groups放到request域中
    request.setAttribute("indexGroups",groups);

%>
<%--table处和tbody处都需要显式列出 width="100%" align="center" --%>
<table class="content-table" width="100%" align="center">
    <thead>
        <tr>
            <th>出游地</th>
            <th>人数</th>
            <th><u>队伍名</u></th>
        </tr>
    </thead>
    <tbody width="100%" align="center">
        <c:forEach items="${indexGroups}" var="group" begin="0" end="4">
            <tr>
                <td>${group.destinations}</td>
                <td>${group.numOfPeople}</td>
                <td>
                    <%--点击的时候，将groupId发送过去，类型是Integer--%>
                    <a href="/group/concreteGroup?groupId=${group.groupId}">
                        ${group.groupName}
                    </a>
                </td>
            </tr>
        </c:forEach>
    </tbody>
</table>

<%
    //关闭流；暂时不管
    //UtilSqlSession.destroySqlSession();
%>
</body>

<%--js--%>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script>
</script>
</html>
